<?php
header("Content-Type: text/html;charset=utf-8");
include_once("WxPayHelper.php");


$commonUtil = new CommonUtil();
$wxPayHelper = new WxPayHelper();


$wxPayHelper->setParameter("bank_type", "WX");
$wxPayHelper->setParameter("body", "布加迪N辆");
$wxPayHelper->setParameter("partner", "1219005701");
$wxPayHelper->setParameter("out_trade_no", $commonUtil->create_noncestr());
$wxPayHelper->setParameter("total_fee", "1");
$wxPayHelper->setParameter("fee_type", "1");
$wxPayHelper->setParameter("notify_url", "http://xxx.xxx.com/onlinepay/wx/serverReceive.php");
$wxPayHelper->setParameter("spbill_create_ip", "127.0.0.1");
$wxPayHelper->setParameter("input_charset", "UTF-8");

?>
<html>
<head>
    <title>微信支付</title>
    <script type="text/javascript" src="/framework/jquery/jquery.min.js?v=20140719"></script>
    <script type="text/javascript" src="/framework/jquery/jquery-migrate-1.1.1.js?v=20140719"></script>




    <script language="javascript">

        function wxpay()
        {
            WeixinJSBridge.invoke('getBrandWCPayRequest',<?php echo $wxPayHelper->create_biz_package(); ?>,function(res){
                WeixinJSBridge.log(res.err_msg);
                alert(res.err_code+res.err_desc+res.err_msg);
            });
        }


//        document.onreadystatechange = subSomething;//当页面加载状态改变的时候执行这个方法.
//        function subSomething()
//        {
//            if(document.readyState == "complete") //当页面加载状态为完全结束时进入
//            wxpay();
//        }
//        document.onreadystatechange = wxpay;
//        window.onload = function(){
//            alert(1);
//            wxpay();
//            alert(2);
//        };
//        $(document).ready(function(){
//
//        });

    </script>
</head>
<body>

</body>

</html>
<script type="text/javascript">
    $(document).ready(function(){
        setTimeout('wxpay()',0);

    });
</script>
